/**
 * Copyright (c) 2024,  科泰集团教研团队
 * 版权所有，请勿侵权
 */
package factory;

import dao.PetDao;
import dao.PetDaoMySQLImpl;
import dao.PetDaoOracleImpl;

/**
 * @author 科泰集团教研团队
 * @version 1.0.0
 * @packageName factory
 * @fileName PetDaoFactory.java
 * @createTime 2024/9/5 22:46
 * @lastModify 2024/9/5 22:46
 */
public class PetDaoFactory {

    // 此默认名称可以通过读取properties配置文件进行修改
    public static String defaultBeanName = "petDaoMySQLImpl";
    /**
     * 负责根据名称获取对应的PetDao实现对象
     * @param beanName
     * @return
     */
    public static PetDao getInstance(String beanName){
        PetDao petDao = null;
        switch (beanName){
            case "petDaoMySQLImpl":
                petDao = new PetDaoMySQLImpl();
                break;
            case "petDaoOracleImpl":
                petDao = new PetDaoOracleImpl();
                break;
            default:
                throw new RuntimeException("未找到'" + beanName + "'对应的对象.");
        }
        return petDao;
    }
}
